home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
gnu
/
amiga
/
lbt92041.lha
/
README
< prev
next >
Wrap
Text File
|
1992-04-14
|
4KB
|
112 lines
The contents of this archive are COPYRIGHT by Markus M. Wild (C) 1992.
The contents are subject to the GNU General Public License (included
in the file `COPYING').
As a special exception, if you link this library with files
compiled with GCC to produce an executable, this does not cause
the resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License.
This is an experimental library package for gcc (used with the GNU ld linker)
that allows you to automatically open/close shared Amiga libraries, as long
as the library base in question is referenced as an external symbol.
Thus, in the following simple program, the <inline/intuition.h> file
references `IntuitionBase' as an external reference:
-----------------------------------------------------------------------------
#include <exec/types.h>
#include <intuition/intuition.h>
#include <inline/intuition.h>
main()
{
long secs, mics;
CurrentTime (&secs, &mics);
printf ("%d, %d\n", secs, mics);
}
-----------------------------------------------------------------------------
If you don't link with -lauto, you get an unresolved symbol error, which
is a healthy thing.. (so *don't* define IntuitionBase in your program, or
the linker won't have a chance to notice you didn't specify -lauto !!!)
To compile this program, use for example:
gcc test.c -o test -lauto
Good luck! I generated entries for the libraries I had fd files for, look
at the Makefile as a guideline how to add new entries for new libraries.
If you want to restrict automatic opening of a certain library to a
specific version number (say to allow only 2.0 libraries), you can define
an __auto* version variable. The correct name for each library is
__auto_XYZ_vers, where XYZ is the name (lowercase) of the fd file without
the "_lib.fd" ending. Thus in the above example, having
-----------------------------------------------------------------------------
int __auto_intuition_vers = 37;
main()
{
...
-----------------------------------------------------------------------------
would only allow a version 37 intuition library to be used (not too
reasonable with CurrentTime() though ;-)).
HOW IT WORKS
------------
Simplified: to support C++, GNU ld supports the concept of constructors and
destructors. These are functions that are called before rsp. after the
main() function is executed. What libauto.a does is provide object files
that export library bases. In each of those files, constructors and
destructors are provided that call OpenLibrary() on the library in question
(and CloseLibrary() in the destructor). That way, main() never has to
open any libraries itself, it can rely on the fact that it gets initialized
library bases, and that the libraries are closed after the program
terminates.
If you want to know how it really works, look at base.c ;-)) (constructors
and destructors are not supported as is, they are implemented on top of
SET objects).
*********
IMPORTANT
*********
o Destructors (that close the libraries!) are only called if you never call
_exit() in your program! If you call _exit(), your automatically opened
libraries are never closed!
o Calling of constructors only works if you compile your main file (the
file containing a main() function) with gcc2.0 !! gcc-1.40 doesn't generate
a call to initialize constructors !!
This is a highly experimental library that I made up because I got some
requests for this feature (DICE seems to support this as well in a similar
yet not identical way). Please tell me about problems you find, or about
things you'd prefer to be done in a different way. I'm open to any
reasonable suggestions, as this is a feature I won't use too often myself,
since I don't regularly program with Amiga libraries other than Exec and
DOS...
-Markus Wild
<wild@nessie.cs.id.ethz.ch> or <wild@amiga.physik.unizh.ch>
send flames to <bitbucket@nessie.cs.id.ethz.ch> (but don't overflood
nessie's /dev/null please ;-)).